package com.qf.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;

/**
 * 微信支付配置类
 * 微信之父 （张小龙）
 */
@Configuration
public class WxConfig {

    @Bean
    public WXPayConfig wxPayConfig(){
        WXPayConfig config = new WXPayConfig() {
            @Override
            public String getAppID() {
                return "wx632c8f211f8122c6";
            }

            @Override
            public String getMchID() {
                return "1497984412";
            }

            @Override
            public String getKey() {
                return "sbNCm1JnevqI36LrEaxFwcaT0hkGxFnC";
            }

            @Override
            public InputStream getCertStream() {
                return null;
            }

            @Override
            public int getHttpConnectTimeoutMs() {
                return 0;
            }

            @Override
            public int getHttpReadTimeoutMs() {
                return 0;
            }
        };
        return config;
    }


    /**
     * 从IOC容器中获取 WXPayConfig 类型的bean，在方法中使用
     * @return
     */
    @Bean
    public WXPay wxPay(WXPayConfig wxPayConfig){
        WXPay wxPay = new WXPay(wxPayConfig);
        return wxPay;
    }


}
